package day0213;

import java.util.Arrays;

public class ArrayDemo10 {

    public static void main(String[] args) {
        /*
            根据数学成绩升序排序后输出
         */
        String[] names = {"张三", "李四", "王五", "赵六"};
        // 语 数 英
        double[][] scores = {
                {89.5, 90, 78.5},
                {92, 99.5, 79},
                {88.5, 93.5, 90},
                {98, 95, 93}
        };

        for (int i = 0; i < scores.length - 1; i++) {

            for (int j = 0; j < scores.length - 1 - i; j++) {

                if (scores[j][1] > scores[j + 1][1]){
                    // 成绩交换位置
                    double[] temp = scores[j];
                    scores[j] = scores[j + 1];
                    scores[j + 1] = temp;
                    // 姓名交换位置

                    String str = names[j];
                    names[j] = names[j + 1];
                    names[j + 1] = str;
                }
            }
        }

        for (int i = 0; i < scores.length; i++) {
            System.out.println(names[i] + " 的成绩是： " + Arrays.toString(scores[i]));
        }
    }
}
